﻿using System;
using System.Xml.Serialization;
using Newtonsoft.Json;
using WJ.Infrastructure.Util;

namespace WJ.Infrastructure.WeChat.Model.Pay
{
 
    public class WeAppPayParam
    {
        /// <summary>
        /// 小程序ID
        /// </summary>
        [JsonIgnore]
        public string appId { get; set; }
        
        /// <summary>
        /// 时间戳 从1970年1月1日00:00:00至今的秒数,即当前的时间
        /// </summary>
        public string timeStamp { get; set; }
        
        /// <summary>
        /// 随机串 随机字符串，不长于32位
        /// </summary>
        public string nonceStr { get; set; }
        
        /// <summary>
        /// 统一下单接口返回的 prepay_id 参数值，提交格式如：prepay_id=wx2017033010242291fcfe0db70013231072
        /// </summary>
        public string package { get; set; }
        
        /// <summary>
        /// 签名方式 签名算法，暂支持 MD5
        /// </summary>
        public string signType { get; set; }
        
        public string paySign { get; set; }

        public WeAppPayParam()
        {
            
        }

        public WeAppPayParam(LoginType type)
        {
            nonceStr = Guid.NewGuid().ToString().Replace("-", "");
            signType = "MD5";
            timeStamp = Convert.ToInt32(DateTimeTool.ToUnixTimestamp(DateTime.Now)).ToString();
            appId = Config.GetAppConfig(type).AppId;
        }
    }
}